home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
stv.lha
/
STV
/
ISA
/
artifact
/
globeref.st
< prev
next >
Wrap
Text File
|
1993-07-23
|
2KB
|
59 lines
" Global Var References by Tom Wrensch & Gene Korienek
This will add a method to the SystemDictionary
(Smalltalk) to open a method browser on all the
methods that use a particular global variable.
For example, If you want to see all the methods
that access the global variable Sources you could
do this:
Smalltalk globalUsers: #Sources.
Remember that classes are also global variables,
so you can also do stuff like this:
Smalltalk globalUsers: #TextPane.
To get all the methods that use the class TextPane
directly.
You may notice that the method browser does not
highlight the place where the global variable is
used. This is unfortunate, but I haven't figured
out how to fix it without major changes to the
method browser."!
!Behavior methods !
usersOf: anObject
"Answer a collection of methods of myself and my
subclasses that use the object anObject."
| methods |
methods := OrderedCollection new: 30.
self withAllSubclasses do: [:class |
class methodDictionary do: [:method |
(method includes: anObject with: nil)
ifTrue: [methods add: method]].
class class methodDictionary do: [:method |
(method includes: anObject with: nil)
ifTrue: [methods add: method]]].
^methods! !
!SystemDictionary methods !
globalUsers: aSymbol
"Pop-up a method list window for the
global variable referenced by aSymbol."
| methods assoc |
CursorManager execute change.
assoc := Smalltalk
associationAt: aSymbol
ifAbsent: [Association new].
methods := Object usersOf: assoc.
CursorManager normal change.
MethodBrowser new
label: 'Users of ', assoc key printString;
openOn: methods! !